var TotalFiles = 0;
function AddFiles()
{
    TotalFiles ++;
    var file=document.createElement("input"); 
    file.type = "file";
    file.id = "f"+ TotalFiles.toString();
    file.name = "files"+ TotalFiles.toString(); 
    file.hideFocus = true;
    file.style.cssText = "cursor:pointer; width:1px; border:none; height:32px; padding:0px; margin:0px;position:absolute; opacity:0;filter:alpha(opacity=0);font-size:20px;";
    file.onchange = function ()
    {
    	var options = {
	      url: pathHeader+'/user/userAvatarUpload.htm',
	      type: 'post',
	      success: function(data) {
    		var path = (data.split(',')[0]).split('=')[1];
    		var message = (data.split(',')[1]).split('=')[1];
    		var width = (data.split(',')[2]).split('=')[1];
    		var height = (data.split(',')[3]).split('=')[1];
    		setTimeout(function()
    			{
    				if(message != null && message != '' && message != 'null'){
    					if(message == "type"){
    						message = "目前仅支持JPG格式图片，请重新上传";
    					}else if(message == "large"){
    						message = "上传图片最大为5M，请重新上传";
    					}
    					$('#uploadMessage').html(message);
    				}else{
    					showImage(path,width,height);
    					$('#uploadMessage').html("");
    				}
    			},1000
    		);
	      }
    	}
		$('#userAvatarUpload').ajaxSubmit(options); 
    };
    document.getElementById("UpFilePanelHidden").appendChild(file);
    var div=document.createElement("div"); 
    div.id = "s"+ TotalFiles.toString();
    document.getElementById("UpFilePanelShow").appendChild(div);
		return false;

}
function DelFile(str)
{
    document.getElementById("UpFilePanelHidden").removeChild(document.getElementById("f"+str));
    document.getElementById("UpFilePanelShow").removeChild(document.getElementById("s"+str));    
}
function DelEmpty()
{
    for (var i=1;i<=TotalFiles;i++)
    {
        if (document.getElementById("f"+i.toString()))
        {
            if (document.getElementById("f"+i.toString()).value == "")
                document.getElementById("UpFilePanelHidden").removeChild(document.getElementById("f"+i.toString()));
        }
            
    }
}